<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?python
colors = ["green", "red", "darkgrey"]
relations = ["brother", "parent", "child"]
protocol = {0: "PyHMon", 10: "PyHMon SSL"}
?>

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#"
    py:extends="'master.kid'">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" py:replace="''"/>
<title>Server list - PyHMon Web Interface</title>
</head>
<body>
    <span py:if="int(parent[0]) != 0">
	<h2>Servers under the server "${parent[1]}"</h2>
	<form action="add_child" method="post">
	<input type = "hidden" name = "parentid" value = "${parent[0]}"/>
	Add child: <select name="child">
	    <option py:for="s in allserver" value="${s.server_id}">
		${s.name}</option>
        </select>
	<input type="submit" name="submit" value="Add"/>
	</form>
    </span><span py:if="int(child[0]) != 0">
	<h2>Servers above the server "${child[1]}"</h2>
	<form action="add_parent" method="post">
	<input type = "hidden" name = "childid" value = "${child[0]}"/>
	Add parent: <select name="parent">
	    <option py:for="s in allserver" value="${s.server_id}">
		${s.name}</option>
        </select>
	<input type="submit" name="submit" value="Add"/>
	</form>
    </span><span py:if="int(parent[0]) + int(child[0]) == 0">
	<h2>Servers</h2>
	<a href="${tg.url('/server_opts')}">Add server</a>
    </span>
    <table border="1" width = "100%">
	<tr>
	    <th>Name</th><th>Address</th><th>Port</th><th>Alert Port</th>
	    <th>Proto</th><th>Edit</th>
	    <span py:if="int(parent[0]) + int(child[0]) == 0">
		<th>Delete</th></span>
	    <span py:if="int(parent[0]) + int(child[0]) != 0">
		<th>Remove</th></span>
        </tr>
	<tr py:for="s in servers"><td>
	    <font py:attrs="{'color':colors[s.status]}"><b>
            <span py:replace="s.name">Name Here.</span>
	    </b></font>
	</td><td>

	    <span py:replace="s.addr">Address Goes Here</span>
	</td><td>
	    <span py:replace="s.port">Port Goes Here</span>
        </td><td>
	    <span py:replace="s.alertport">Alert Port Goes Here</span>
        </td><td>
	    <span py:replace="protocol[s.proto]">Protocol Goes Here</span>
        </td><td>
	<form action="server_opts" method="post">
            <input type="hidden" name="serverid" value="${s.server_id}"/>
            <input type="submit" name="submit" value="Go!"/>
        </form>
	</td><td>
	<form action="del_server" method="post">
            <input type="hidden" name="serverid" value="${s.server_id}"/>
            <input type="hidden" name="parentid" value="${parent[0]}"/>
            <input type="hidden" name="childid" value="${child[0]}"/>
            <input type="submit" name="submit" value="Go!"/>
        </form>
	</td></tr>
    </table>
</body>
</html>
